import string
 
alphabet = "abcdefghijklmnopqrstuvwxyz "

def encode(words):
    word = words.lower()
    encodestring = {'a':'n', 'b':'o', 'c':'p', 'd':'q', 'e':'r', 'f':'s', 'g':'t', 'h':'u', 'i':'v', 'j':'w', 'k':'x', 'l':'y', 'm':'z', 'n':'a', 'o':'b', 'p':'c', 'q':'d', 'r':'e', 's':'f', 't':'g', 'u':'h', 'v':'i', 'w':'j', 'x':'k', 'y':'l', 'z':'m', '1':'#',  '2':'*',  '3':'+',  '4':'@',  '5':'~',  '6':':',  '7':'%',  '8':'3',  '9':'}',  '!':'>',  '@':'{',  '#':'^',  '$':'&',  '%':';',  '^':'?',  '&':'1',  '*':'7',  '(':'2',  ')':'6',  '-':'<',  '_':'5', '=':'>',   '+':')',  '`':'9',  '~':'{',  '[':',',  '{':'+',  ']':'4', '}':'8',  '"':'/',  ':':'`',  '?':']', '/':'-',   '>':'0', '.':'"', '<':'/',  ',':',', '0':'$', ' ':' ', }
    new_words = ""
    for letter in word:
        if letter in alphabet:
            new_words = new_words + encodestring[letter]
            #continue
            #new_words = new_words + letter
    return new_words

def decode(words):
    word = words.lower()
    decodestring = {'n':'a', 'o':'b', 'p':'c', 'q':'d', 'r':'e', 's':'f', 't':'g', 'u':'h', 'v':'i', 'w':'j', 'x':'k', 'y':'l', 'z':'m', 'a':'n', 'b':'o', 'c':'p', 'd':'q', 'e':'r', 'f':'s', 'g':'t', 'h':'u', 'i':'v', 'j':'w', 'k':'x', 'l':'y', 'm':'z', '#':'1',  '*':'2',  '+':'3',  '@':'4',  '~':'5',  ':':'6',  '%':'7',  '3':'8',  '{':'9',  '>':'!',  '{':'@',  '^':'#',  '&':'$',  ';':'%',  '?':'^',  '1':'&',  '7':'*',  '2':'(',  '6':')',  '<':'-',  '5':'_',  '>':'=',  ')':'+',  '9':'`',  '{':'~',  ',':'[',  '+':'{',  '4':']',  '8':'}',  '/':'"',  '`':':',  '[':'?',  '-':'/',  '0':'>',  '.':'"',  '/':'<',  '!':',',  '$':'0', ' ':' ' }
    new_words = ""
    for letter in word:
        if letter in alphabet:
            new_words = new_words + decodestring[letter]
            #continue
            #new_words = new_words + letter
    return new_words


def menu(choice):
    if choice == 1 or choice == 2:
        str1 = raw_input("Message: ").lower()
        str2 = encode(str1)
        print "This is your message after being encoded."
        print str2
        raw_input("Enter to continue")
    if choice == 2:
        str1 = raw_input("Message: ").lower()
        str2 = decode(str1)
        print "This is your message after being decoded."
        print str2
        raw_input("Enter to continue")
    else:
        print 'you must enter a number\nyour options are...'
        choce()

def choce():
    print "1 = encode\n2 = decode"
    ask1 = raw_input("What would you like to do? ")
    ask = int(ask1)
    menu(ask)










